<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            margin: 0 auto;
            border: 1px solid black;
            background-color: bisque;
            position: absolute;
        }
    </style>
</head>
<div id="box">
    <h3>我是弹出框</h3>
</div>
<body>
    <script>
        box.onmousedown =function(event){
            var reX =event.offsetX
            var reY =event.offsetY
            console.log(reX);
            document.onmousemove = function(event){
                box.style.left =event.clientX-reX+'px'
                box.style.top =event.clientY-reY+'px'
            }
        }
        document.onmouseup=function(){
            document.onmousemove =null
        }
    </script>
</body>
</html>